package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppHistoricalData;
import com.ep.modules.app.service.AppHistoricalDataService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/historical_data")
public class AppHistoricalDataController {
    @Autowired
    private AppHistoricalDataService appHistoricalDataService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appHistoricalDataService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppHistoricalData apphistoricaldata = appHistoricalDataService.getById(id);
        return R.ok().put("apphistoricaldata", apphistoricaldata);
    }

    @SysLog("保存AppHistoricalData")
    @PostMapping("/save")
    public R save(@RequestBody AppHistoricalData apphistoricaldata) {
        ValidatorUtils.validateEntity(apphistoricaldata);
        appHistoricalDataService.save(apphistoricaldata);
        return R.ok();
    }

    @SysLog("修改AppHistoricalData")
    @PostMapping("/update")
    public R update(@RequestBody AppHistoricalData apphistoricaldata) {
        ValidatorUtils.validateEntity(apphistoricaldata);
        appHistoricalDataService.update(apphistoricaldata);
        return R.ok();
    }

    @SysLog("删除AppHistoricalData")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appHistoricalDataService.deleteBatch(ids);
        return R.ok();
    }
}